class Feed::OrderMadeItemCreated < Feed
  
  validates :order_id,
    :presence =>true,
    :if => 'order_item_id.present?'  
  validates :installation_id,
    :presence =>true,
    :if => 'install_item_id.present?'
  validates :furniture_id,
    :order_made_id,
    :order_made_item_id,
    :presence =>true 
  
  before_create do |feed|    
    if install_item.present?
      self.order_id = install_item.order_id
      self.order_item_id = install_item.order_item_id
    end
  end

  def code
    ActiveSupport::StringInquirer.new('has_been_sent_to_factory')
  end
  
  def short_desc
    "#{order_made.creator.full_name}于#{order_made.order_made_on}向【#{furniture.furniture_style.factory.name}】<b>下单订做</b>【 #{order_made_item.order_made_count}件】"
  end
  
  def remark
    order_made_item.remark
  end
end